#!/bin/bash
DT=`date -d '-1 day' +%Y-%m-%d`

/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.customer where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_customer \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.customer_appeal where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_customer_appeal \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.customer_clue where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_customer_clue \
-m 1



/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.customer_relationship where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_customer_relationship \
-m 1



/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.employee where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_employee \
-m 1



/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.itcast_school where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_itcast_school \
-m 1



/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.itcast_subject where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_itcast_subject \
-m 1


/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "SELECT *, '${DT}' as dt FROM scrm.scrm_department where 1=1 and (create_date_time BETWEEN '2010-01-01 00:00:00' and '${DT} 23:59:59') OR (update_date_time between '2010-01-01 00:00:00' and '${DT} 23:59:59') and \$CONDITIONS" \
--hcatalog-database zx_ods \
--hcatalog-table ods_scrm_department \
-m 1

